package lianxiyong.test;

import com.sun.corba.se.impl.orbutil.ObjectWriter;
import com.zrrf.demo.F;

import java.io.*;
import java.util.Properties;

public class myproperties {
    public static void main(String[] args) throws IOException {
        Properties prop = new Properties();
        prop.setProperty("user", "12");
        prop.setProperty("pass", "18");
        FileWriter a =new FileWriter("D:abc.txt");
        prop.store(a,"zheshi");
        a.close();
        FileReader b =new FileReader("D:abc.txt");
        Properties prop1 = new Properties();
        prop1.load(b);
        String o =prop1.getProperty("user");
        String p =prop1.getProperty("pass");
        students s =new students(o,p);
        System.out.println(s.getName()+"  "+s.getAge());
        FileOutputStream fos = null;
        ObjectOutputStream oos = null;
        try{
            fos = new FileOutputStream("D:abc.txt");
            oos = new ObjectOutputStream(fos);
            oos.writeObject(s);
            oos.close();
            fos.close();
        }catch (FileNotFoundException e){
            e.printStackTrace();
        }

    }
}
class students implements Serializable{
    String name;
    String age;
    public students(String name, String age) {
        this.name = name;
        this.age = age;

    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAge() {
        return age;
    }
    public void setAge(String age) {
        this.age = age;
    }
}

